/**
 * 
 */
package com.xy.commons;


/**
 * @author admin 进度数据转换工具
 */
public class DecimalUtil {

	private static final String digit = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	/**
	 * baseString 递归调用
	 * 
	 * @param num
	 *            十进制数
	 * @param base
	 *            要转换成的进制数
	 */
	public static String baseString(int num, int base) {
		String str = "";
		if (num != 0) {
			str = baseString(num / base, base);
			str = str + digit.charAt(num % base);
		}
		return str;
	}

	public static void main(String[] args) {
		System.out.println(baseString(72, 36));

	}
	
	/**
     * 将时间字符串加入分隔符号，如20130101010101可分为2013-01-01 01:01:01
     * @param str 需要分隔的字符串
     * @param flag 分隔标志，如“-”
     * @return String 分隔后的字符串
     * */
    public static String addFlagHour(String str,String flag)
    {
        if ( null != str && !"".equals(str) )
        {
            if ( 14 <= str.length() )
            {
                String year = str.substring(0, 4);
                String month = str.substring(4, 6);
                String day = str.substring(6, 8);
                String hour = str.substring(8, 10);
                String min = str.substring(10, 12);
                String second = str.substring(12, 14);
                
                return year+"-"+month+"-"+day+" "+hour+":"+min+":"+second;
            }
            else
            {
                return str;
            }
        }
        else
        {
            return str;
        }
    }
}
